package cn.xopencode.scoreservice.provider.demand;
import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.score.api.rpc.ScoreRpc;
import cn.xopencode.score.api.rpc.demand.dto.ScoreAllDTO;
import cn.xopencode.score.api.rpc.demand.dto.ScoreReqDTO;
import cn.xopencode.score.api.rpc.demand.dto.ScoreRespDTO;
import cn.xopencode.scoreservice.service.demand.ScoreService;
import cn.xopencode.securityservice.rpc.activity.dto.ActivityCreateReqDTO;
import cn.xopencode.securityservice.rpc.suggest.dto.SuggestCreateReqDTO;
import cn.xopencode.securityservice.rpc.violate.dto.ViolateCreateReqDTO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import static cn.xopencode.common.framework.vo.CommonResult.success;


/**
 * 积分改变 Rpc 实现
 */
@DubboService(version = "${dubbo.provider.ScoreRpc.version}")
public class ScoreRpcProviderImpl implements ScoreRpc {
    @Autowired
    private ScoreService scoreService;

    @Override
    public CommonResult<List<ScoreAllDTO>> getScoreDetails(String id) {
        return success(scoreService.getDetailsScore(id));
    }

    @Override
    public CommonResult<PageResult<ScoreRespDTO>> getPageScore(ScoreReqDTO scoreReqDTO) {
        return success(scoreService.pageScore(scoreReqDTO));
    }

    @Override
    public CommonResult<ScoreRespDTO> getScoreFromDate(ScoreReqDTO scoreReqDTO) {
        return success(scoreService.getScoreFromDate(scoreReqDTO));
    }

    /**
     * 创新与合理化建议
     * @param createDTO
     * @return 修改分的分数
     */
    @Override
    public Double addSuggestScore(SuggestCreateReqDTO createDTO) {
        return scoreService.addSuggestScore(createDTO);
    }

    /**
     * 安全活动与技能比武情况
     * @param createDTO
     * @return
     */
    @Override
    public Double addActivityScore(ActivityCreateReqDTO createDTO) {
        return scoreService.addActivityScore(createDTO);
    }

    /**
     * 反三违及事故情况
     * @param createDTO
     * @return
     */
    @Override
    public void updateViolateScore(ViolateCreateReqDTO createDTO) {
        scoreService.updateViolateScore(createDTO);
    }


}
